﻿#Persistent
FileEncoding UTF-8
SendMode Input

lastSentDate := ""  ; 记录上一次发送的日期

SetTimer, CheckTime, 3000  ; 每3秒检查一次
return

CheckTime:
FormatTime, CurrentTime,, HH:mm
FormatTime, Today,, yyyyMMdd
; 如果当前时间大于等于 09:00 且今天没发过
; if (CurrentTime = "11:13" && lastSentDate != Today) {
if (lastSentDate != Today) {
    lastSentDate := Today
    SendMessageToAssistant()
}
return

SendMessageToAssistant() {
    Run, "C:\Program Files\Tencent\Weixin\Weixin.exe"
    WinWait, ahk_exe Weixin.exe, , 20
    if ErrorLevel
        return

    WinActivate, ahk_exe Weixin.exe
    WinWaitActive, ahk_exe Weixin.exe

    Sleep, 500
    Send, ^f
    Sleep, 300
    Send, 文件传输助手
    Sleep, 500

    ; 点击搜索结果
    Click, 230, 230
    Sleep, 500

    ; 点击输入框
    Click, 300, 560
    Sleep, 300

    ; 输入并发送
    Send, 早上好!
    Sleep, 300
    Send, !s
}
